public class ExtendTest2{
    public static void main(String[] args){
        
        Super test = new Sub();
        test.goDie();
        System.out.println("test.name: " + test.name);
        test.changeName();        
        System.out.println("test.name: " + test.name);
        test.showName();
        
        System.out.println("\n**************");
        
        Super test2;
        Sub tmp = new Sub();
        test2 = tmp;
        test2.goDie();
        System.out.println("test2.name: " + test2.name);
        test2.changeName();
        System.out.println("test2.name: " + test2.name);
        test2.showName();
    }
}

class Super{
    String name = "Super Class";
    void goDie(){
        System.out.println(name + " go die.");
    }
    void changeName(){
        name = "heihei";
    }
    void showName(){
        System.out.println("show name: " + name);
    }
}

class Sub extends Super{
    String name = "Sub Class";
    void goDie(){
        System.out.println("name is " + this.name);
        System.out.println(name + " go die. and earth blow up");
    }
    void changeName(){
        name = "haha";
    }
    
    void showName(){
        System.out.println("show name: " + name);
    }
}